<template>
  <a-card :bordered="false">
    <!-- 查询区域 -->
    <div class="table-page-search-wrapper">
      <a-form layout="inline" @keyup.enter.native="searchQuery">
        <a-row :gutter="24">
          <a-col :xl="6" :lg="6" :md="12" :sm="24">
            <a-form-item label="姓名">
              <a-input-number style="width:100%" placeholder="请输入姓名" v-model="queryParam.name" ></a-input-number>
            </a-form-item>
          </a-col>
          <a-col :xl="6" :lg="6" :md="12" :sm="24">
            <a-form-item label="年级">
              <a-select default-value="1" placeholder="选择年级" v-model="queryParam.grade" >
                <a-select-option :value="item.val" v-for="(item, index) in gradeUl" :key="index" >{{ item.name }}</a-select-option >
              </a-select>
            </a-form-item>
          </a-col>
          <a-col :xl="6" :lg="7" :md="8" :sm="24" >
            <a-form-item label="时间筛选">
              <a-range-picker @change="panelChange" v-model="queryParamRangePicker"/>
            </a-form-item>
          </a-col>
          <a-col :xl="6" :lg="6" :md="12" :sm="24">
            <span style="float: left; overflow: hidden" class="table-page-search-submitButtons" >
              <a-button type="primary" @click="searchQuery" icon="search" >查询</a-button >
              <a-button type="primary" @click="searchReset" icon="reload" style="margin-left: 8px" >重置</a-button >
            </span>
          </a-col>
        </a-row>
      </a-form>
    </div>

    <!-- table区域-begin -->
    <div>
      <a-table 
        ref="table" 
        size="middle" 
        bordered 
        rowKey="id" 
        :scroll="{ x: 1300 }" 
        :columns="columns" 
        :dataSource="tableData" 
        :pagination="ipagination" 
        :loading="loading" 
        @change="handleTableChange" >
      </a-table>
    </div>
    <!-- table区域-end -->

    <!-- 表单区域 -->
  </a-card>
</template>

<script>
import ApiTree from "@/api/evaluation/questionsList";
import { Slime, crud } from "@/mixins/slime";

export default {
  name: "historyList",
  mixins: [Slime],
  components: {},
  data() {
    return {
      gradeUl:[
        {name:'初中', val:1},
        {name:'高中', val:2},
      ],
      tableData: [],
      columns: [
        {
          title: "手机号",
          align: "center",
          dataIndex: "mobile",
        },
        {
          title: "名字",
          align: "center",
          dataIndex: "name",
        },
        {
          title: "头像",
          align: "center",
          dataIndex: "avatar",
          scopedSlots: { customRender: 'imgPath' },
        },
        {
          title: "职位",
          align: "center",
          dataIndex: "position",
        },
        {
          title: "从业年限",
          align: "center",
          dataIndex: "grade",
        },
        {
          title: "擅长",
          align: "center",
          dataIndex: "skill",
          scopedSlots: { customRender: 'catList' },
        },
      ],
    };
  },
  created() {
    this.loadData();
  },
  methods: {
    // 加载表格数据
    loadData(arg) {
      crud(ApiTree);
      this.loadDataPack(arg).then((res) => {
        let tableData = [];
        if (res.result) {
          tableData = res.result.records;
        }
        this.tableData = tableData;
      });
    },
    //改变筛选时间
    panelChange(date){
      let startTime = moment(date[0]).format('YYYY-MM-DD');
      let endTime = moment(date[1]).format('YYYY-MM-DD');
      this.queryParam = {...this.queryParam, startTime:startTime, endTime:endTime}
    },
  },
};
</script>
<style scoped>
</style>